home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / system / chang412.zip / CHANGE.DOC < prev    next >
Text File  |  1994-12-14  |  18KB  |  368 lines

  1. CHANGE.DOC
  2. 12/14/94
  3.  
  4. Program written by:
  5.                         Bruce Guthrie
  6.                         Room H-4885
  7.                         U.S. Dept of Commerce/ESA/OBA/BSISD
  8.                         Washington, D.C. 20230
  9.  
  10.                         (202) 482-3234
  11.  
  12. You may freely copy and re-distribute this program; however, the U.S.
  13. Department of Commerce neither guarantees nor assures compatibility of the
  14. program with all computer software or hardware.
  15.  
  16. Foreign users:  Please provide an Internet e-mail address in all correspondence
  17. or and just e-mail your problems to me at bgu@cu.nih.gov
  18.  
  19.  
  20. The CHANGE.EXE program allows you to make changes in binary or text files of any
  21. size.  Features:
  22.  
  23.   * Can handle files of any size provided you have enough room on your disk
  24.     to hold a copy of resulting file
  25.   * Can be used to change text files or binary files
  26.   * Can be used to remove trailing spaces from a file
  27.   * Can specify different lengths for the input strings and the output strings
  28.   * Can specify that the changes only be done in lines that include a certain
  29.     character string.  This selection string can be case-insensitive
  30.   * Can handle up to 30 change requests at a time
  31.   * Can specify the input/output strings as ASCII characters, hexadecimal
  32.     values, or as decimal values
  33.   * Handles the changes fairly quickly
  34.   * Can either replace the original file with the resulting file or else
  35.     create a new changed file (using /Noutfile specification)
  36.   * Changes can be verified before they are made
  37.   * Changes can be entered in any of the following ways:
  38.       - from the command line (one TO/FROM pair allowed)
  39.       - interactively (one TO/FROM pair allowed)
  40.       - from a controlfile (up to 30 TO/FROM pairs allowed)
  41.   * Boolean operators can be used if the TO/FROM pair is specified from the
  42.     command line (e.g. CHANGE TEST.TXT /FROM One /TO Many /IN Apples OR Oranges
  43.  
  44. The CHANGE program does not support standard wildcards for the input file names.
  45. You can use the DOS FOR command to handle this if you'd like:
  46.  
  47.         FOR %a IN (A*.TXT C*.DOC) DO CHANGE %a /FROM "One" /TO "Another"
  48.  
  49.  
  50. The CHANGE.INI file:
  51.  
  52. CHANGE will read a CHANGE.INI file if one is found.  (You can specify a
  53. different file name if desired.) The file is an ASCII text file that can be
  54. created maintained by hand.  The file can consist or one or more command line
  55. parameters (only those that begin with a "/"), one statement per line.
  56.  
  57. The file can also contain comments which are blank lines or any line beginning
  58. with:
  59.         ;    (semi-colon)
  60.         :    (colon)
  61.         '    (quote)
  62.  
  63. CHANGE looks for the initialization file in your default subdirectory first.  It
  64. then searches for it in the subdirectory where the executable was and then goes
  65. through your DOS path.
  66.  
  67. Passing in "/INULL" skips loading the INI file.  This saves some execution time
  68. as the program does not need to search your path for the file.  Do *NOT* use
  69. "/-I" for this or you will turn off case sensitivity in the search.
  70.  
  71.  
  72. CONFIGWS.EXE:
  73.  
  74. In addition to using the CHANGE.INI file, you can permanently change some
  75. defaults within CHANGE.EXE by using the CONFIGWS.EXE program.  CONFIGWS.EXE is
  76. not included in the CHANGE distribution package but previous versions can
  77. typically be used with CHANGE if desired.  (The same CONFIGWS.EXE program can
  78. be used to path a number of Wayne Software programs.) If CONFIGWS can't patch
  79. the executable, it will notify you of this before altering anything.
  80.  
  81. CONFIGWS.EXE allows you to set the following defaults:
  82.  
  83.         Reverse criteria: /V or /-V
  84.         Case insensitive: /I or /-I
  85.  
  86. When setting options, the program will process defaults in the following order:
  87.   (1) CONFIGWS.EXE-settable settings
  88.   (2) CHANGE.INI settings
  89.   (3) command-line settings
  90.  
  91. The *last* settings encountered win.
  92.  
  93.  
  94.  
  95. Syntax:
  96.  
  97.     CHANGE infile [ /Cctlfile | /FROM string /TO string [ /IN search ] ]
  98.       [ /LINES { line1-line2 | line1 linect } ... ] [ /V | /-V ] [ /I | /-I ]
  99.       [ /Noutfile [ /OVERWRITE | /-OVERWRITE | /OVERASK ] ]
  100.       [ /Iinitfile ] [ /Fflagfile ] [ /Ttempfile ] [ /TRIM | /-TRIM ]
  101.       [ /BINARY | /TEXT ] [ /VERIFY | /-VERIFY ] [ /Q ] [ /? | /?&H ]
  102.  
  103. where:
  104.  
  105. "infile" can include a drive and path designation.  It is the file name you
  106. want changed.  Unless you specify a /Noutfile parameter, the infile will be
  107. overwritten by this program.
  108.  
  109. "/Cctlfile" contains the change commands to make.  If a ctlfile is not provided
  110. and a FROM/TO option is not specified, the routine will prompt you for one FROM
  111. (what's the text you want to change from; case is significant unless /I is
  112. specified), TO (what's the text you want to change to; case is always
  113. significant), and IN (what string the line must be contain before the change is
  114. applied; case is always significant unless /I is specified) request.  If a
  115. ctlfile is used, you can specify up to 30 change requests at a time.  Each line
  116. of the change file should consist of records of one of four record types:
  117.  
  118.   * blank lines or those beginning with semi-colons are treated as comments.
  119.   * lines beginning with "-F" or "-f" provide FROM options.
  120.   * lines beginning with "-T" or "-t" provide TO options.
  121.   * lines beginning with "-I" or "-i" provide IN options.  These are optional;
  122.     if not provided, all lines will be searched for the FROM string.  Any
  123.     IN request forces /TEXT mode to be invoked
  124.  
  125. If more than one set of FROM/TO/IN records is provided, the -F specification
  126. (for a control file) must precede the others.  Each option is local to a given
  127. FROM/TO/IN specification.  For example:
  128.  
  129.         ; Sample control file
  130.         -FPRINT
  131.         -TPrinting
  132.         -I"
  133.         -fUSING
  134.         -tused
  135.  
  136. contains two FROM/TO/IN specifications.  "PRINT" will be changed to "Printing"
  137. in any line with a double quote.  "USING" will be changed to "used" in all
  138. lines; no -I option is applied for the second FROM/TO/IN specification.
  139.  
  140. The FROM/TO/IN specifications can include any text characters.  They can also
  141. contain ASCII codes, created either using the Alt key in combination with the
  142. numeric keypad (e.g.  Alt-228 to get a Sigma character) or else by embedding a
  143. hexadecimal code (in the form &Hxx) or a decimal code (in the form \nnn) in the
  144. text.  You can get a table of hexadecimal codes at the end of this documentation
  145. or by saying "CHANGE /?&H".  For example, to change a double carriage
  146. return/line feed to a single carriage return/line feed, you could say:
  147.  
  148.         -F&H0D0A0D0A
  149.         -T&H0D0A
  150.  
  151.  
  152. (Note that the above example would require you to use the /BINARY option as well
  153. since it extends beyond line boundaries.)
  154.  
  155. If you need to follow a hexadecimal specification with normal text characters,
  156. follow the hex spec with one space (which CHANGE will ignore).  For example,
  157.  
  158.         -F&H0c Hi!
  159.         -T&H0d0a Bye!
  160.  
  161. To remove a string entirely, use the -T without anything after it or use
  162. "-TNULL" or "/TO NULL" from the command line.
  163.  
  164. "/FROM string /TO string [ /IN search ]" allows you to specify the from/to
  165. parameters on the control line.  Quotation marks are required around the strings
  166. if they include spaces or special characters.  Note that certain characters
  167. cannot be passed in because DOS considers them special characters and steals
  168. them first.  This includes ">" and "|" characters.  You'll have to use the
  169. control file or the interactive mode in this case or else use the &Hxx or \nnn
  170. conventions.  "search" is further described below.  To eliminate a string
  171. entirely, use "/TO NULL" or use the control file instead.
  172.  
  173. "/Iinitfile" says to read an initialization file with the file name "initfile".
  174. The file specification *must* contain a period.  If no drive or path information
  175. is specified, the program will search for initfile beginning in your default
  176. subdirectory and then going throughout your DOS path.  The use of an
  177. initialization file is optional.  Initially defaults to "/ICHANGE.INI".
  178. "/INULL" says to skip loading the initialization file.
  179.  
  180. "/LINES line1-line2" says to restrict the search to lines between line numbers
  181. line1 and line2 inclusive.  You can have multiple line requests in any order
  182. such as "/LINES 1-10 90-100 30-50".  The routine skips all lines after the
  183. largest line number is encountered.  Defaults to "/LINES 1-9999999".
  184.  
  185. "/LINES line1 linect" says to restrict the search to lines beginning with line1
  186. and continuing for a total of linect lines.  So "/LINES 10 20" is actually the
  187. same as "/LINES 10-29".
  188.  
  189. "/V" says to find those items that do NOT match the specification.
  190.  
  191. "/-V" is the opposite of /V and is typically the default; CONFIGWS-able.
  192.  
  193. "/I" says to make it a case-insensitive search.
  194.  
  195. "/-I" is the opposite of /I and is typically the default; CONFIGWS-able.
  196.  
  197. "/Noutfile" is the name of the new file to create.  If a /Noutfile is not
  198. specified, the source document (infile) will be replaced by the changed file.
  199.  
  200. "/OVERWRITE" says to write over the outfile (if requested) if it exists
  201. already.
  202.  
  203. "/-OVERWRITE" says to abort if the outfile exists already.
  204.  
  205. "/OVERASK" says to ask if the outfile exists already.  This is the default.
  206.  
  207.  
  208. "/Fflagfile" is the name of a file to contain all changed lines.  This allows
  209. you to see what the lines were changed to for verification purposes.  This
  210. option automatically invokes /TEXT.
  211.  
  212. "/Ttempfile" is the name of the temporary file to create.  The actual changes
  213. are written to a temp file and then the source file is replaced with the temp
  214. file is everything works and there were actually changes to be found in the
  215. source document.  By default, the temp file is written to the same path as the
  216. input file.  The temporary file will be as big as the final file is.  If you
  217. don't have enough room for it to be on your source disk, specify another
  218. temporary file name with a different path (e.g. "/TG:\TEMP.TXT").
  219.  
  220. "/TRIM" says to remove trailing spaces from the end of each line.  Automatically
  221. forces you into TEXT mode.
  222.  
  223. "/-TRIM" is the opposite of /TRIM and is the default.
  224.  
  225. "/TEXT" puts you into TEXT mode.  TEXT mode means that all data in the file are
  226. read in and processed as separate text records.  Alternatively, the file can be
  227. processed in BINARY mode in which case the file is read in in 8,000-byte blocks.
  228. BINARY mode is quicker and is required for EXE and COM files.  TEXT mode
  229. presents some information like the number of lines in your file and is
  230. *required* if you specify any of the following options:
  231.  
  232.         * an IN (or -I) request
  233.         * /LINES
  234.         * /Fflagfile
  235.         * /TRIM
  236.         * /VERIFY
  237.  
  238. "/BINARY" is the opposite of TEXT mode.  It's faster than TEXT and is the
  239. default for CHANGE.  It is overridden if you specify certain options listed
  240. above.
  241.  
  242. "/VERIFY" says to prompt you before changing any lines.  You are asked to
  243. confirm that you in fact want to make each change requested.  Automatically
  244. forces you into TEXT mode.
  245.  
  246. "/-VERIFY" is the opposite of /VERIFY and is the default.
  247.  
  248. "/Q" turns off the line-by-line status messages.
  249.  
  250. "/?" or "/HELP" or "HELP" shows you the syntax for the command.
  251.  
  252. "/?&H" gives you a hexadecimal and decimal conversion table.
  253.  
  254.  
  255.  
  256. For search, the syntax is:
  257.   [ ( ]... search_item [ boolean [ ( ]... search_item [ ) ]...] [ ) ]...
  258. where:
  259.   ( and )     are used to group items
  260.   search_item is shown below
  261.   boolean     is AND, OR, or XOR (NOT is included with search_item)
  262.  
  263. for search_item, the syntax is:
  264.   [ NOT ]  "string" [ column ]
  265. where:
  266.   NOT         is obvious
  267.   string      the string to search; the quotation marks are typically not
  268.               required unless the string contains a space or a reserved word
  269.   column      is the column in which the string must be found.
  270.  
  271. So, let's cover some examples:
  272.  
  273.         CHANGE TEST.TXT /FROM Apple /TO Banana /IN "Bugs Bunny" OR "Elmer Fudd"
  274.  
  275. Changes the string "Apple" to "Banana" in any lines that have either the text
  276. "Bugs Bunny" or "Elmer Fudd" in them.
  277.  
  278.         CHANGE TEST2.TXT /FROM Bugs /TO Bunny /IN (Apples or Oranges) AND NOT
  279.            Pears /LINES=1-1000 /COLS=1/5
  280.  
  281. Changes "Bugs" to "Bunny" in the first thousand lines of TEST2.TXT.  The line
  282. itself must contain the words "Apples" or "Oranges" in them and any lines are
  283. ignored that contain "Pears".  Note that the quotes around the search words are
  284. not required unless the words include spaces or unless they could be confused
  285. with some other keywords.  "CHANGE TEST3.TXT /FROM Bugs /TO Bunny /IN OR OR AND"
  286. might cause the program to get confused since "OR" and "AND", which you want to
  287. look for as also keywords.
  288.  
  289.         CHANGE /I TEST.TXT /FROM One /TO Many /IN "Bugs Bunny" AND Martians
  290.  
  291. This changes "One" to "Many" is any lines that contain both "Bugs Bunny" and
  292. "Martians".  The search is case-insensitive so lines with either "BUGS BUNNY"
  293. and "Bugs Bunny" will be changed.
  294.  
  295. NOTE:  THIS EXTENDED SEARCHING CAPABILITY IS SUPPORTED ONLY FOR /IN REQUESTS
  296. MADE FROM THE COMMAND LINE.  IT IS NOT SUPPORTED IN EITHER THE CTLFILE OR IN THE
  297. INTERACTIVE TO/FROM SELECTION MODE.
  298.  
  299.  
  300. Return codes:
  301.  
  302. CHANGE returns the following ERRORLEVEL codes:
  303.         0 = no problems, changes made
  304.         1 = no problems, nothing found to change
  305.       253 = routine aborted early
  306.       254 = internal problems
  307.       255 = syntax problems, file not found, or /? requested
  308.  
  309.  
  310. Decimal and hexadecimal codes:
  311.   e.g. "\066\097\116" and "&H426174" both are "Bat"
  312. +---------------------------------------------------------------------------
  313. | dec  hex chr | dec  hex chr | dec  hex chr | dec  hex chr | dec  hex chr |
  314. +--------------+--------------+--------------+--------------+--------------+
  315. | \000 &H00 nul| \052 &H34 4  | \104 &H68 h  | \156 &H9C £  | \208 &HD0 ╨  |
  316. | \001 &H01   | \053 &H35 5  | \105 &H69 i  | \157 &H9D ¥  | \209 &HD1 ╤  |
  317. | \002 &H02   | \054 &H36 6  | \106 &H6A j  | \158 &H9E ₧  | \210 &HD2 ╥  |
  318. | \003 &H03   | \055 &H37 7  | \107 &H6B k  | \159 &H9F ƒ  | \211 &HD3 ╙  |
  319. | \004 &H04   | \056 &H38 8  | \108 &H6C l  | \160 &HA0 á  | \212 &HD4 ╘  |
  320. | \005 &H05   | \057 &H39 9  | \109 &H6D m  | \161 &HA1 í  | \213 &HD5 ╒  |
  321. | \006 &H06   | \058 &H3A :  | \110 &H6E n  | \162 &HA2 ó  | \214 &HD6 ╓  |
  322. | \007 &H07 bel| \059 &H3B ;  | \111 &H6F o  | \163 &HA3 ú  | \215 &HD7 ╫  |
  323. | \008 &H08 bs | \060 &H3C <  | \112 &H70 p  | \164 &HA4 ñ  | \216 &HD8 ╪  |
  324. | \009 &H09 tab| \061 &H3D =  | \113 &H71 q  | \165 &HA5 Ñ  | \217 &HD9 ┘  |
  325. | \010 &H0A lf | \062 &H3E >  | \114 &H72 r  | \166 &HA6 ª  | \218 &HDA ┌  |
  326. | \011 &H0B vt | \063 &H3F ?  | \115 &H73 s  | \167 &HA7 º  | \219 &HDB █  |
  327. | \012 &H0C pg | \064 &H40 @  | \116 &H74 t  | \168 &HA8 ¿  | \220 &HDC ▄  |
  328. | \013 &H0D cr | \065 &H41 A  | \117 &H75 u  | \169 &HA9 ⌐  | \221 &HDD ▌  |
  329. | \014 &H0E   | \066 &H42 B  | \118 &H76 v  | \170 &HAA ¬  | \222 &HDE ▐  |
  330. | \015 &H0F   | \067 &H43 C  | \119 &H77 w  | \171 &HAB ½  | \223 &HDF ▀  |
  331. | \016 &H10   | \068 &H44 D  | \120 &H78 x  | \172 &HAC ¼  | \224 &HE0 α  |
  332. | \017 &H11   | \069 &H45 E  | \121 &H79 y  | \173 &HAD ¡  | \225 &HE1 ß  |
  333. | \018 &H12   | \070 &H46 F  | \122 &H7A z  | \174 &HAE «  | \226 &HE2 Γ  |
  334. | \019 &H13   | \071 &H47 G  | \123 &H7B {  | \175 &HAF »  | \227 &HE3 π  |
  335. | \020 &H14   | \072 &H48 H  | \124 &H7C |  | \176 &HB0 ░  | \228 &HE4 Σ  |
  336. | \021 &H15   | \073 &H49 I  | \125 &H7D }  | \177 &HB1 ▒  | \229 &HE5 σ  |
  337. | \022 &H16   | \074 &H4A J  | \126 &H7E ~  | \178 &HB2 ▓  | \230 &HE6 µ  |
  338. | \023 &H17   | \075 &H4B K  | \127 &H7F   | \179 &HB3 │  | \231 &HE7 τ  |
  339. | \024 &H18   | \076 &H4C L  | \128 &H80 Ç  | \180 &HB4 ┤  | \232 &HE8 Φ  |
  340. | \025 &H19   | \077 &H4D M  | \129 &H81 ü  | \181 &HB5 ╡  | \233 &HE9 Θ  |
  341. | \026 &H1A eof| \078 &H4E N  | \130 &H82 é  | \182 &HB6 ╢  | \234 &HEA Ω  |
  342. | \027 &H1B esc| \079 &H4F O  | \131 &H83 â  | \183 &HB7 ╖  | \235 &HEB δ  |
  343. | \028 &H1C   | \080 &H50 P  | \132 &H84 ä  | \184 &HB8 ╕  | \236 &HEC ∞  |
  344. | \029 &H1D ???| \081 &H51 Q  | \133 &H85 à  | \185 &HB9 ╣  | \237 &HED φ  |
  345. | \030 &H1E ???| \082 &H52 R  | \134 &H86 å  | \186 &HBA ║  | \238 &HEE ε  |
  346. | \031 &H1F ???| \083 &H53 S  | \135 &H87 ç  | \187 &HBB ╗  | \239 &HEF ∩  |
  347. | \032 &H20    | \084 &H54 T  | \136 &H88 ê  | \188 &HBC ╝  | \240 &HF0 ≡  |
  348. | \033 &H21 !  | \085 &H55 U  | \137 &H89 ë  | \189 &HBD ╜  | \241 &HF1 ±  |
  349. | \034 &H22 "  | \086 &H56 V  | \138 &H8A è  | \190 &HBE ╛  | \242 &HF2 ≥  |
  350. | \035 &H23 #  | \087 &H57 W  | \139 &H8B ï  | \191 &HBF ┐  | \243 &HF3 ≤  |
  351. | \036 &H24 $  | \088 &H58 X  | \140 &H8C î  | \192 &HC0 └  | \244 &HF4 ⌠  |
  352. | \037 &H25 %  | \089 &H59 Y  | \141 &H8D ì  | \193 &HC1 ┴  | \245 &HF5 ⌡  |
  353. | \038 &H26 &  | \090 &H5A Z  | \142 &H8E Ä  | \194 &HC2 ┬  | \246 &HF6 ÷  |
  354. | \039 &H27 '  | \091 &H5B [  | \143 &H8F Å  | \195 &HC3 ├  | \247 &HF7 ≈  |
  355. | \040 &H28 (  | \092 &H5C \  | \144 &H90 É  | \196 &HC4 ─  | \248 &HF8 °  |
  356. | \041 &H29 )  | \093 &H5D ]  | \145 &H91 æ  | \197 &HC5 ┼  | \249 &HF9 ∙  |
  357. | \042 &H2A *  | \094 &H5E ^  | \146 &H92 Æ  | \198 &HC6 ╞  | \250 &HFA ·  |
  358. | \043 &H2B +  | \095 &H5F _  | \147 &H93 ô  | \199 &HC7 ╟  | \251 &HFB √  |
  359. | \044 &H2C ,  | \096 &H60 `  | \148 &H94 ö  | \200 &HC8 ╚  | \252 &HFC ⁿ  |
  360. | \045 &H2D -  | \097 &H61 a  | \149 &H95 ò  | \201 &HC9 ╔  | \253 &HFD ²  |
  361. | \046 &H2E .  | \098 &H62 b  | \150 &H96 û  | \202 &HCA ╩  | \254 &HFE ■  |
  362. | \047 &H2F /  | \099 &H63 c  | \151 &H97 ù  | \203 &HCB ╦  | \255 &HFF    |
  363. | \048 &H30 0  | \100 &H64 d  | \152 &H98 ÿ  | \204 &HCC ╠  |              |
  364. | \049 &H31 1  | \101 &H65 e  | \153 &H99 Ö  | \205 &HCD ═  |              |
  365. | \050 &H32 2  | \102 &H66 f  | \154 &H9A Ü  | \206 &HCE ╬  |              |
  366. | \051 &H33 3  | \103 &H67 g  | \155 &H9B ¢  | \207 &HCF ╧  |              |
  367. +--------------+--------------+--------------+--------------+--------------+
  368.